<?php

namespace App\Models;

use Carbon\Carbon;

class UserStatus extends Model
{
    protected $table = 'user_status';

    // ============= scope ==========



    // ============= field ==========
    public function setUserId($userId)
    {
        $this->user_id = $userId;
    }


    public function getTestLevel()
    {
        return $this->test_level;
    }

    public function setTestLevel($evaluateLevel)
    {
        $this->test_level = $evaluateLevel;
    }

    public function getCurrentLevel()
    {
        return $this->current_level;
    }

    public function setCurrentLevel($level)
    {
        $this->current_level = $level;
    }

    public function getWordCount()
    {
        return $this->word_count;
    }

    public function setWordCount($wordCount)
    {
        $this->word_count = $wordCount;
    }

    public function getLessonCount()
    {
        return $this->lesson_count;
    }

    public function getDubCount()
    {
        return $this->dub_count;
    }

    public function setStartStudyTime($time)
    {
        $this->start_study_time = $time;
    }

    public static function getStudyTime($userId)
    {
        $startTime = static::query()->where('user_id', $userId)->value('start_study_time');
        $week = Carbon::now()->diffInWeeks($startTime) + 1;
        return [
            'startTime' => $startTime,
            'week' => $week
        ];
    }
}
